package com.aaron.messenger.data;

import java.util.ArrayList;

public class ChatMessage extends UdpPacket {
	public static final int TYPE_STRING = 0;
	public static final int TYPE_IMAGE = 1;
	
	long id;
	int subid;
	int packetnum;
	ArrayList<String> data;
	byte metadata;

	int dataoffset;
	
	public ChatMessage() {
		dataoffset = 0;
		data = new ArrayList<String>();
	}
	
	public void setId(long id) {
		this.id = id;
	}
	
	public void setPacketNum(int num) {
		this.packetnum = num;
	}
	
	public void setSubId(int sub) {
		this.subid = sub;
	}
	
	public void appendData(String data, int type) {
		this.data.add(data);
		metadata |= type<<dataoffset;
		dataoffset++ ;
	}
	
	public String toString() {
		StringBuilder sb = new StringBuilder();
		sb.append("Id:"+id+"    Subid:"+subid+"    Data:");
		for(String str:data) {
			sb.append(str);
		}
		return sb.toString();
	}
	
	public ArrayList<String> getData() {
		return data;
	}
}
